package hms.RoomManagementModule;

import hms.rooms.Room;

import java.awt.BorderLayout;
import java.awt.Dialog;
import java.awt.Font;

import javax.swing.ButtonGroup;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.border.BevelBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;

public class DecommissionPanel extends JDialog {

	protected final JPanel contentPanel = new JPanel();
	private Room room;
	private ManageRoomsView view;
	private ManageRoomsPanel parent;
	
	protected JLabel lbl_roomLabel;
	protected JTextField txt_specifyOther;

	protected ButtonGroup radioButtonGroup;
	
	protected JRadioButton radio_maintenance, radio_cleaning, radio_remodeling, radio_other;
	protected JButton btn_decommissionConfirmation;
	
	private void setValuesForComponents(){
		lbl_roomLabel.setText("Room: " + room.getRoomLabel());
	}
	/**
	 * Create the dialog.
	 */
	public DecommissionPanel(Room i_room, ManageRoomsView i_view, ManageRoomsPanel i_parent) {
		view = i_view;
		parent = i_parent;
		room = i_room;
		setAlwaysOnTop(true);
		setLocationByPlatform(true);
		setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
		setResizable(false);
		setTitle("Decommission Room");
		
		setBounds(100, 100, 218, 260);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		
		lbl_roomLabel = new JLabel("Room:");
		lbl_roomLabel.setFont(new Font("SansSerif", Font.PLAIN, 16));
		
		JPanel panel = new JPanel();
		panel.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
		
		btn_decommissionConfirmation = new JButton("Decommission");
		btn_decommissionConfirmation.setActionCommand("btn_decommissionConfirmation");
		btn_decommissionConfirmation.addActionListener(i_view);
		
		
		
		GroupLayout gl_contentPanel = new GroupLayout(contentPanel);
		gl_contentPanel.setHorizontalGroup(
			gl_contentPanel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_contentPanel.createSequentialGroup()
					.addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_contentPanel.createSequentialGroup()
							.addContainerGap()
							.addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING)
								.addComponent(panel, GroupLayout.PREFERRED_SIZE, 181, GroupLayout.PREFERRED_SIZE)
								.addComponent(lbl_roomLabel)))
						.addGroup(gl_contentPanel.createSequentialGroup()
							.addGap(52)
							.addComponent(btn_decommissionConfirmation)))
					.addContainerGap(11, Short.MAX_VALUE))
		);
		gl_contentPanel.setVerticalGroup(
			gl_contentPanel.createParallelGroup(Alignment.TRAILING)
				.addGroup(Alignment.LEADING, gl_contentPanel.createSequentialGroup()
					.addContainerGap()
					.addComponent(lbl_roomLabel, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(panel, GroupLayout.PREFERRED_SIZE, 148, GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(ComponentPlacement.RELATED, 13, Short.MAX_VALUE)
					.addComponent(btn_decommissionConfirmation))
		);
		
		radio_maintenance = new JRadioButton("Maintenance");
		radio_maintenance.setSelected(true);
		radio_maintenance.setActionCommand("radio_all_except_others");
		radio_maintenance.addActionListener(i_view);
		
		radio_cleaning = new JRadioButton("Cleaning");
		radio_cleaning.setActionCommand("radio_all_except_others");
		radio_cleaning.addActionListener(i_view);
		
		radio_remodeling = new JRadioButton("Remodeling");
		radio_remodeling.setActionCommand("radio_all_except_others");
		radio_remodeling.addActionListener(i_view);
		
		radio_other = new JRadioButton("Other: (specify)");
		radio_other.setActionCommand("radio_other");
		radio_other.addActionListener(i_view);
		
		radioButtonGroup = new ButtonGroup();
		radioButtonGroup.add(radio_maintenance);
		radioButtonGroup.add(radio_cleaning);
		radioButtonGroup.add(radio_remodeling);
		radioButtonGroup.add(radio_other);
		
		txt_specifyOther = new JTextField();
		txt_specifyOther.setEnabled(false);
		txt_specifyOther.setColumns(10);
		GroupLayout gl_panel = new GroupLayout(panel);
		gl_panel.setHorizontalGroup(
			gl_panel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_panel.createSequentialGroup()
					.addContainerGap()
					.addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
						.addComponent(txt_specifyOther, GroupLayout.DEFAULT_SIZE, 157, Short.MAX_VALUE)
						.addComponent(radio_maintenance)
						.addComponent(radio_cleaning, GroupLayout.PREFERRED_SIZE, 93, GroupLayout.PREFERRED_SIZE)
						.addComponent(radio_remodeling, GroupLayout.PREFERRED_SIZE, 93, GroupLayout.PREFERRED_SIZE)
						.addComponent(radio_other, GroupLayout.PREFERRED_SIZE, 142, GroupLayout.PREFERRED_SIZE))
					.addContainerGap())
		);
		gl_panel.setVerticalGroup(
			gl_panel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_panel.createSequentialGroup()
					.addContainerGap()
					.addComponent(radio_maintenance)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(radio_cleaning)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(radio_remodeling)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(radio_other)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(txt_specifyOther, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
		);
		panel.setLayout(gl_panel);
		contentPanel.setLayout(gl_contentPanel);
		
		setValuesForComponents();
	}
}
